<template>
  <el-carousel class="carousel-container" trigger="click" indicator-position="none" arrow="always">
    <el-carousel-item v-for="item in imgList" :key="item.imgUrl">
      <router-link :to="`/msgDetail/${item.companyId}?type=2`">
        <img :src="item.imgUrl" />
      </router-link>
    </el-carousel-item>
  </el-carousel>
</template>

<script setup lang="ts">
import { ElCarousel, ElCarouselItem } from "element-plus";
import { getSlideshowApi } from "@/api/homePage/slideshowApi";
import { ref } from "vue";

const imgList: any = ref([]);

(async () => {
  const data = await getSlideshowApi();
  imgList.value = data;
})();
</script>

<style scoped lang="scss">
@import "@/css/respondMixin";
@import "@/css/variable";

.carousel-container {
  width: $contentwidth;
  margin: 0 auto;
  @include respond-to("phone") {
    width: auto;
  }
}

:deep(.el-carousel__container) {
  height: 400px !important;

  @include respond-to("phone") {
    height: 200px !important;
  }
}

img {
  object-fit: cover;
  height: 100%;
  width: 100%;
}
</style>
